/****************************************************************
 * <strong>MFCrossSQL</strong>
 *
 * <p>
 * MFCrossSQL
 * </p>
 *
 * @author AndyZhang 2011 cnet2001@163.com
 * @version 0.1
 * ToDo:2011-11-22
 ***************************************************************/
package com.thinkwide.data.ormapping.dialect;

import com.thinkwide.data.ormapping.MFDataAdapter;

public class MFOperateCrossSql {

    private MFCrossSql crossSQL;

    public MFOperateCrossSql(MFDataAdapter dataAdapter) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
		/*
		String name=dataAdapter.getDbName();
		
		if (MFString.isNullOrEmpty(name))
			name=MFDataAdapter.defDB;
		
		MFConnectionInfo info =MFDataManager.getConnectionInfo(name);
		String dc=info.getAdapterClasses();
		*/

        String dc = dataAdapter.getTransaction().getAdapterClasses();

        Class<?> c = Class.forName(dc);
        Object obj = c.newInstance();
        MFCrossSql xcrossSQL = (MFCrossSql) obj;
        setCrossSql(xcrossSQL);

    }

    public String getSelectPageSql(String tableName, String where, String orderBy, int beginIndex, int endIndex) {
        return crossSQL.getSelectPageSql(tableName, where, orderBy, beginIndex, endIndex);
    }

    public String getSelectPageSqlExt(String sql, String where, String orderBy, int beginIndex, int endIndex) {
        return crossSQL.getSelectPageSqlExt(sql, where, orderBy, beginIndex, endIndex);
    }

    public String getSelectPageSql(String sql, int beginIndex, int endIndex) {
        return crossSQL.getSelectPageSql(sql, beginIndex, endIndex);
    }

    public void setCrossSql(MFCrossSql crossSQL) {
        this.crossSQL = crossSQL;
    }

    public MFCrossSql getCrossSql() {
        return crossSQL;
    }
}
